package br.ufrj.dcc.comp2.musica.vista;

import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import br.ufrj.dcc.comp2.musica.controle.ControleCardLayout;
import br.ufrj.dcc.comp2.musica.listeners.ListenerSolicitarInscricao;

public class PainelSolicitarIncricao extends JPanel {
	private ControleCardLayout controleCardLayout;
	private JLabel labelDisciplina = new JLabel("Nome da Disciplina:");
	// private JLabel labelTurmasDisponiveis = new JLabel("Turmas
	// Disponiveis:");
	// private JLabel labelProfessor = new JLabel("Professor:");
	// private JLabel labelHorario = new JLabel("Horario:");
	private JLabel labelTitulo = new JLabel("Lista das Disciplinas disponiveis");
	private JComboBox campoDisciplina = new JComboBox();
	// private JComboBox campoTurmasDisponiveis = new JComboBox();
	// private JLabel labelProfessorSelecionado = new JLabel("Roberta Santos
	// Lopes");
	// private JLabel labelHorarioSelecionado = new JLabel("8hs ate 10 hs");
	private ScrollPaneTabelaDisciplinasDisponiveis scroll;
	private JButton botaoConfirmar = new JButton("Confirmar");

	GridBagLayout gridBagLayout = new GridBagLayout();
	GridBagConstraints gridBagConstraints = new GridBagConstraints();

	public PainelSolicitarIncricao(ControleCardLayout controleCardLayout) {
		this.controleCardLayout = controleCardLayout;
		setBorder(BorderFactory.createTitledBorder("Solicitar Disciplina"));
		setLayout(gridBagLayout);
		scroll = new ScrollPaneTabelaDisciplinasDisponiveis();
		botaoConfirmar.addActionListener(new ListenerSolicitarInscricao(scroll, this));

		gridBagConstraints.insets = new Insets(5, 5, 5, 5);

		adicionar(labelDisciplina, 1, 1);
		// adicionar(labelTurmasDisponiveis, 1, 2);
		// adicionar(labelProfessor, 1, 3);
		// adicionar(labelHorario, 1, 4);
		adicionar(labelTitulo, 1, 2);

		adicionar(campoDisciplina, 2, 1);
		// adicionar(campoTurmasDisponiveis, 2, 2);
		// adicionar(labelProfessorSelecionado, 2, 3);
		// adicionar(labelHorarioSelecionado, 2, 4);

		gridBagConstraints.gridwidth = 2;
		adicionar(scroll, 1, 3);

		adicionar(botaoConfirmar, 2, 4, GridBagConstraints.CENTER);
	}

	public void adicionar(Component c, int x, int y) {
		gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
		gridBagConstraints.gridx = x;
		gridBagConstraints.gridy = y;
		gridBagConstraints.ipady = 3;

		add(c, gridBagConstraints);
	}

	public ControleCardLayout getControleCardLayout() {
		return controleCardLayout;
	}

	public void setControleCardLayout(ControleCardLayout controleCardLayout) {
		this.controleCardLayout = controleCardLayout;
	}

	public void adicionar(Component c, int x, int y, int fill) {
		gridBagConstraints.fill = fill;
		gridBagConstraints.gridx = x;
		gridBagConstraints.gridy = y;
		gridBagConstraints.ipady = 3;

		add(c, gridBagConstraints);
	}

	public JComboBox getCampoDisciplina() {
		return campoDisciplina;
	}

}